RandomStandardNormal
生成服从标准正态分布 \(\mathcal{N}(0, 1)\) 的随机数序列。
\[output_i \sim \mathcal{N}(0, 1)\]
- 输入:
length - 输出数据长度。
seed - 随机数种子,用于控制生成序列的随机性。
core_mask(int, 可选) - 核掩码(仅适用于共享存储版本)。
- 输出:
output - 生成的标准正态分布随机数地址。
- 支持平台:
FT78NEMT7004
备注
FT78NE 支持 fp32
MT7004 支持 fp32, fp16
相同的种子可生成相同的随机数序列(确定性行为)。
随机数生成使用 Box–Muller 算法实现。
共享存储版本:
-
void fp_random_standard_normal_s(float *output, int length, unsigned int seed, int core_mask)
-
void hp_random_standard_normal_s(half *output, int length, unsigned int seed, int core_mask)
C 调用示例:
1// FT78NE 示例 2#include <stdio.h> 3 4int main(int argc, char* argv[]) { 5 float *output = (float *)0xA0000000; // output 在 DDR 空间 6 int length = 1024; 7 unsigned int seed = 1234; 8 int core_mask = 0xff; 9 fp_random_standard_normal_s(output, length, seed, core_mask); 10 return 0; 11}
私有存储版本:
-
void fp_random_standard_normal_p(float *output, int length, unsigned int seed)
-
void hp_random_standard_normal_p(half *output, int length, unsigned int seed)
C 调用示例:
1// MT7004 示例 2#include <stdio.h> 3 4int main(int argc, char* argv[]) { 5 float *output = (float *)0x10010000; 6 int length = 1024; 7 unsigned int seed = 1234; 8 fp_random_standard_normal_p(output, length, seed); 9 return 0; 10}